home *** CD-ROM | disk | FTP | other *** search
- Path: vb.franken.de!volker
- From: volker@vb.franken.de (Volker Barthelmann)
- Subject: Re: 680X0 -> PPC translator?
- Newsgroups: comp.sys.amiga.programmer
- References: <31499F8E.26A9@netvision.net.il> <volker.0fw1@vb.franken.de> <315800D7.1854@sapiens.com> <volker.0g32@vb.franken.de> <315C198B.49C2@netvision.net.il>
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
- Message-ID: <volker.0g5w@vb.franken.de>
- Date: 31 Mar 96 01:55:19 MET
- Organization: home
-
- Jack (avilev@netvision.net.il) wrote:
- : Hi Volker, well i'll try to keep the lines shorter this time
- : so you'll be able to read the text more conveniently and who
-
- Thanks!
-
- : know. you might actually be convinced that 680x0 -> PPC is possible. ;-)
-
- I doubt that. :-)
-
- : > Perhaps You can perform this analysis. An algorithm can't.
- :
- : why the hell not, if i can understand assembly source code,
- : the machine can understand machine code right?!
-
- I don't know if You (or any human) can really 'understand' EVERY
- piece of machine code. Of course typical assembly source can be
- understood by humans, because it was written with that in mind.
-
- : > Of course You can have a structure holding all Your variables. Now You pass
- : > the address of this structure to an external function that writes some
- : > values into it and You lost.
- :
- : i don't seem to care about that, get it through your head, i'm NOT
- : going to intervene with what the program does with any memory area,
- : just as long as this memory area is not later being used for code
-
- Unfortunately You have to know about all other memory areas as well,
- because otherwise You cannot determine what is code and what is data.
-
- Think about: The program writes a value somwhere. Then copies it around,
- shifts it, moves it again etc. and than sometimes it reads it from where
- it is now, loads it in a0 and does a jmp (a0) or so.
-
- : execution. then, and only then will i have to turn to all the locations
- : where that pointer could have been assigned and then change the size
- : argument which i already know to the appropriate sizes, once i figure
- : out that the area is code, i will perform a well defined series of actions
- : to resolve ALL dependecies related to that area, including size, write loops etc.
-
- Well, please define those 'well defined' series of actions.
-
- : > There are several memory allocating functions or other functions You can't
- : > know anything about.
- :
- : then you take into account all of the various SYSTEM functions which allocate
- : memory (there aren't many of them) and proceed as normal.
-
- What do You do if a program does an OpenLibrary("some_custom.library",foo);
- and a jsr -some_strange_offset_I've_never_seen_before(a6)?
- This function could call AllocMem. You don't even know what parameters it
- takes etc.
-
- : > You would have to adjust EVERYTHING that is in any way dependant on the code
- : > size! How are You going to do this?
- :
- : all you have to look for is where it was allocated and where it is copied,
- : assuming you're copying code that is. quite easily done if you follow the
- : change made to that pointer while 'running' through the program's logic.
-
- If You write a program that only reads a normal assembly source file that
- is known to copy some piece of code somewhere and Your program can change the
- source to copy one byte more, I'll believe You (and call You god, if You want).
-
- : > : > Easy??
- : > :
- : > : yes easy, cuz as i said you know where it was allocated and you can change the appropriate
- : > : argument.
- : >
- : > Er..have You ever really programmed anything with data flow analysis?
-
- : well actually yes, i did, although it wasn't anywhere near as complex
- : as the problem we're talking about.
-
- Please tell me more, I'm curious!
-
- : > As the size of the sub-allocated memory changes You may have to completely
- : > rewrite the pool-allocator, because it may depend on the allocations being
- : > of certain sizes or a multiple of a certain sizes etc.
- : > To do this the translator would have to completely understand the allocator
- : > and this is impossible.
- :
- : what???? all you have to do is request the allocator for more memory, no need
- : to change anything in the allocator itself. the only possible problem i see here
-
- Yes, You have. E.g. the allocator could assume that all requests are multiples
- of 1024 and rely on that. Now the original code may have been a multiple
- of 1024, but the PPC-code probably isn't. So when You pass the PPC-code-size
- to the allocator it will go nuts.
-
- : granted, you're right about that not all solutions are clear cut but when it comes
- : to exact sciences such as computer-science then i would disagree, especially
- : since the problem we're dealing with isn't related to any human logic, that
- : field even in computer-science hasn't been fully explored and understood yet.
- : no, the only major problem is self-modification of the program otherwise you
- : translate the code 1:1.
-
- Still I claim You can't even reliably decide what is code and what is data.
- Even if self-modifying code is forbidden.
-
- : > I gave several examples. The discussion is rather pointless as long as You
- : > just say 'I keep track of this' and 'adjust that according to xyz' etc.
- : > Of course it's possible to rewrite a program to PPC, but You have to show
- : > that this can be done by an algorithm and this is a different story.
- : >well saying that often doesn't mean it's wrong and it would be foolish not
- : to explore every suggested solution. if you are so convinced it is not
- : possible then surely you can provide me with a concrete proof to undermine
- : my theory, can't you?! remember the burden of proof lies on my shoulders
- : cuz i claim something is possible, so you have to give me an example
- : i can't solve with my theory.
-
- Well, I really thought it would be obvious that there are examples, but
- I'll give You a detailed one if You like:
-
- Assume a program that has some kind of keyfiles. It has n areas that could
- be code or data and Your algorithm has to decide that.
- Assume that the addresses of those areas are in an array adr[n].
- Now the program call the system function Open("env:keyfile",MODE_OLDFILE),
- reads all longwords from the file, adds them up and calls adr[sum%n].
-
- To know which areas could be called You would have to know all valid
- keyfiles. Of course no algorithm knows them and therefore can't decide what
- is code. qed.
-
- : > Once You describe Your algorithm I will happily give You an example.
- :
- : the algorithm mainly revolves around self-modification, otherwise it's
- : a simple translation of code instructions. and my algorithm, though wasn't
-
- No.
-
- : presented in a flow-chart, is presented by words. that doesn't mean it's impossible
- : to write an actual algorithm in a true sense of the word.
-
- Of course You can present an algorithm by words, but You didn't. It was more
- like 'First I look at the program, than I decide what is code and then I
- rewrite it.' That's A BIT vague, I'm afraid.
-
- Volker
-
-